package com.sky.controller.admin;

import com.sky.result.Result;
import com.sky.service.ShopService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.convert.ReadingConverter;
import org.springframework.web.bind.annotation.*;

@RestController("adminShopController")
@Slf4j
@RequestMapping("/admin/shop")
@Api(tags = "客户端店铺相关接口")
public class ShopController {
    @Autowired
    private ShopService shopService;

    /**
     * 设置店铺的营业状态
     * @param status 店铺状态：1 营业中 ，2 打烊中
     * @return code 1, msg null, data null
     */
    @PutMapping("/{status}")
    @ApiOperation("设置店铺的营业状态")
    public Result setStatus(@PathVariable Integer status){
        log.info("设置店铺的营业状态：{}-{}",status,status==1?"营业中":"打烊中");
        Integer Bystatus =shopService.setStatus(status);
        return Result.success(Bystatus);
    }

    /**
     * 获取店铺营业状态
     * @return code 1, msg null, data status
     */
    @GetMapping("/status")
    @ApiOperation("获取店铺营业状态")
    public Result getStatus(){
        Integer status = shopService.getStatus();
//        log.info("店铺营业状态：{}",status);
        log.info("获取店铺营业状态：{}-{}",status,status==1?"营业中":"打烊中");
        return Result.success(status);
    }

}
